package com.example.endusation.config;

import io.milvus.client.MilvusClient;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.ConnectParam;
import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.Driver;
import org.neo4j.driver.GraphDatabase;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class DataConfig {

    // Neo4j配置
    @Value("${neo4j.uri}")
    private String neo4jUri;
    @Value("${neo4j.username}")
    private String neo4jUsername;
    @Value("${neo4j.password}")
    private String neo4jPassword;

    // Milvus配置
    @Value("${milvus.host}")
    private String milvusHost;
    @Value("${milvus.port}")
    private int milvusPort;


    @Bean
    public Driver neo4jDriver() {
        return GraphDatabase.driver(neo4jUri,
                AuthTokens.basic(neo4jUsername, neo4jPassword));
    }

    @Bean
    public MilvusClient milvusClient() {
        ConnectParam connectParam = ConnectParam.newBuilder()
                .withHost(milvusHost)
                .withPort(milvusPort)
                .build();
        return new MilvusServiceClient(connectParam);
    }
}

